<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>银行卡管理</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f5f8fa;
            font-family: 'Inter', sans-serif;
            padding: 20px;
        }

       .container {
            max-width: 1200px;
            margin: 0 auto;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            padding: 25px;
        }

        h2 {
            color: #0f3460;
            margin-bottom: 20px;
            font-weight: 600;
        }

       .search-bar {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }

       .search-bar input {
            flex-grow: 1;
            padding: 8px 12px;
            border: 1px solid #ddd;
            border-radius: 6px;
        }

       .search-bar button {
            background-color: #0f3460;
            color: white;
            border: none;
            border-radius: 6px;
            padding: 8px 15px;
            cursor: pointer;
        }

       .search-bar button:hover {
            background-color: #1a508b;
        }

       .action-buttons {
            margin-bottom: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

       .add-btn {
            background-color: #28a745;
            color: white;
            padding: 8px 15px;
            border-radius: 6px;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }

       .add-btn:hover {
            background-color: #218838;
            color: white;
            text-decoration: none;
        }

       .back-btn {
            color: #0f3460;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }

       .back-btn:hover {
            text-decoration: underline;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }

        th,
        td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }

        th {
            background-color: #f8f9fa;
            color: #0f3460;
            font-weight: 600;
        }

        tr:hover {
            background-color: #f5f5f5;
        }

       .action-link {
            margin-right: 10px;
            text-decoration: none;
            padding: 2px 5px;
            border-radius: 3px;
        }

       .edit-link {
            color: #007bff;
        }

       .edit-link:hover {
            background-color: #e8f4ff;
        }

       .delete-link {
            color: #dc3545;
        }

       .delete-link:hover {
            background-color: #ffebee;
        }
    </style>
</head>

<body>
    <div class="container">
        <h2>银行卡管理</h2>

        {% with messages = get_flashed_messages() %}
        {% if messages %}
        <div class="alert alert-danger" role="alert">
            {% for message in messages %}
            <p>{{ message }}</p>
            {% endfor %}
        </div>
        {% endif %}
        {% endwith %}

<form method="get" action="{{ url_for('admin.list_cards') }}" class="search-bar">
    <input type="text" name="q" placeholder="搜索卡号或客户姓名" value="{{ keyword or '' }}">
    <button type="submit">
        <i class="fa fa-search"></i> 搜索
    </button>
</form>


        <div class="action-buttons">
            <a href="{{ url_for('admin.add_card') }}" class="add-btn">
                <i class="fa fa-plus"></i> 添加银行卡
            </a>
            <a href="{{ url_for('admin.dashboard') }}" class="back-btn">
                <i class="fa fa-arrow-left"></i> 返回仪表盘
            </a>
        </div>

        <table>
            <thead>
                <tr>
                    <th>卡号</th>
                    <th>币种</th>
                    <th>开户日期</th>
                    <th>开户金额</th>
                    <th>余额</th>
                    <th>是否挂失</th>
                    <th>客户姓名</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for card in cards %}
                <tr>
                    <td>{{ card.cardID }}</td>
                    <td>{{ card.curID }}</td>
                    <td>{{ card.openDate }}</td>
                    <td>{{ card.openMoney }}</td>
                    <td>{{ card.balance }}</td>
                    <td>{{ '是' if card.IsReportLoss else '否' }}</td>
                    <td>{{ card.customerName }}</td>
                    <td>
                        <a href="{{ url_for('admin.edit_card', cardID=card.cardID) }}" class="action-link edit-link">
                            <i class="fa fa-pencil"></i> 编辑
                        </a>
                        <form method="POST" action="{{ url_for('admin.delete_card', cardID=card.cardID) }}" style="display:inline;" onsubmit="return confirm('确认删除该银行卡？')">
                            <button type="submit" class="action-link delete-link" style="border:none; background:none;">
                                <i class="fa fa-trash"></i> 删除
                             </button>
                        </form>
                        
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</body>

</html>